<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopCommissionLogTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_commission_log', ['comment' => '分销动态日志', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('agent_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '分销商'])
            ->addColumn('event', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '事件标识:agent=分销商日志,level=等级变动日志,order=分销业绩,team=团队日志,reward=佣金日志,share=分享日志'])
            ->addColumn('remark', 'string', ['limit' => 255, 'null' => true, 'default' => null, 'comment' => '备注'])
            ->addColumn('oper_type', 'string', ['limit' => 60, 'null' => true, 'default' => null, 'comment' => '操作人:admin=管理员,system=系统,user=用户'])
            ->addColumn('oper_id', 'integer', ['limit' =>  11, 'default' => 0, 'comment' => '操作人ID'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addIndex('agent_id')
            ->create();
    }


    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_commission_log');
        $table->drop();
    }
}
